home *** CD-ROM | disk | FTP | other *** search
- /*
- copyright © 1992-1994 Apple Computer Inc. All rights reserved.
-
- CommonCode.c
- This file contains routines that are used by both the old and the new
- API files. We have to include them with both links, and it's best
- to have just use one copy stored here.
-
- Modification history
- 11/16/93 dmh - begat.
- */
-
- #include <GXExceptions.h>
- #include <Packages.h>
- #include <Dialogs.h>
- #include <Errors.h>
- #include <Resources.h>
- #include <PrintingDrivers.h> // Standard printing includes
- #include "CommonDefines.h" // things common to .r and .h files
-
-
- // StoreFmtCollectionItem stores the passed data as specified,
- // in the collection of the passed format.
-
- OSErr StoreFmtCollectionItem(void *collectItem, long collectSize,
- OSType collectType, short collectID,
- gxFormat whichFormat)
- {
- OSErr err;
- Collection fmtCollection;
- long index, itemSize, attributes;
-
- // Get the format collection of the passed format, and see if
- // this item already exists.
-
- fmtCollection = GXGetFormatCollection(whichFormat);
-
- err = GetCollectionItemInfo(fmtCollection,
- collectType,
- collectID,
- &index,
- &itemSize,
- &attributes);
-
-
- // If the collection item already exists, replace the old data with
- // what we were passed. If the item doesn't exist, create it.
-
- if (!err)
- {
- err = ReplaceIndexedCollectionItem(fmtCollection,
- index,
- collectSize,
- collectItem);
- }
- else
- if (err == collectionItemNotFoundErr)
- err = AddCollectionItem(fmtCollection,
- collectType,
- collectID,
- collectSize,
- collectItem);
- return err;
- }
-
-
-
- // GetFmtCollectionItem returns the requested format collection item.
-
- OSErr GetFmtCollectionItem(void *collectItem, long *collectSize,
- OSType collectType, short collectID,
- gxFormat whichFormat)
- {
- OSErr err;
- Collection fmtCollection;
-
- fmtCollection = GXGetFormatCollection(whichFormat);
-
- err = GetCollectionItem(fmtCollection,
- collectType,
- collectID,
- collectSize,
- collectItem);
- return err;
- }
-
-
-
- // SetFormatFlipping simply stores the 'flph' and 'flpv' format
- // collection tags, representing the setting passed. That is,
- //
- // flipSetting == 0 -- no flipping.
- // flipSetting == 1 -- horizontal flipping.
- // flipSetting == 2 -- vertical flipping.
- // flipSetting == 3 -- horizontal & vertical flipping.
- //
- // Note that the 'flph' and 'flpv' tags are only supported by the
- // GX PostScript imaging engine, so we need to provide support for
- // handling these tags ourselves. We do this in the SD_RenderPage
- // routine in NewApp.c
-
- void SetFormatFlipping(char flipSetting, gxFormat whichFormat)
- {
- gxFlipPageHorizontalInfo hFlipInfo;
- gxFlipPageVerticalInfo vFlipInfo;
-
- // Simply store the collection items indicating the requested page
- // flipping.
-
- hFlipInfo.flipHorizontal = (flipSetting & 0x01) != 0;
- vFlipInfo.flipVertical = (flipSetting & 0x02) != 0;
-
- StoreFmtCollectionItem(&hFlipInfo, sizeof(gxFlipPageHorizontalInfo),
- gxFlipPageHorizontalTag, gxPrintingTagID,
- whichFormat);
-
- StoreFmtCollectionItem(&vFlipInfo, sizeof(gxFlipPageVerticalInfo),
- gxFlipPageVerticalTag, gxPrintingTagID,
- whichFormat);
- }
-
-
-
- // GetCurFlip returns a character value which indicates the current
- // flipping settings in the options dialog. The char's value can be
- // interpreted like so:
- //
- // 0 -- no flipping.
- // 1 -- horizontal flipping.
- // 2 -- vertical flipping.
- // 3 -- horizontal & vertical flipping.
- //
- // hFlipBox and vFlipBox are the DITL item numbers of the horizontal
- // and vertical checkboxes in this panel or dialog.
-
-
- char GetCurFlip(DialogPtr theDialog, short hFlipBox, short vFlipBox)
- {
- char curFlipping;
- short itemType;
- Handle itemH;
- Rect itemBox;
-
- GetDItem(theDialog, hFlipBox, &itemType, &itemH, &itemBox);
- curFlipping = GetCtlValue((ControlHandle) itemH);
- GetDItem(theDialog, vFlipBox, &itemType, &itemH, &itemBox);
- curFlipping += GetCtlValue((ControlHandle) itemH) *2;
-
- return curFlipping;
- }
-